package cn.king.springframework.context.annotation;

import cn.hutool.core.util.ClassUtil;
import cn.king.springframework.beans.factory.config.BeanDefinition;
import cn.king.springframework.stereotype.Component;


import java.util.LinkedHashSet;
import java.util.Set;

public class ClassPathScanningCandidateComponentProvider {
    public Set<BeanDefinition> findCandidateComponents(String basePackage){
        Set<BeanDefinition> candicates = new LinkedHashSet<>();
        Set<Class<?>> classes = ClassUtil.scanPackageByAnnotation(basePackage, Component.class);
        for(Class<?> clazz:classes){
            candicates.add(new BeanDefinition(clazz));
        }
        return candicates;
    }

}
